<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
export default {
    mixins: [Vue.prototype.$vFN.Mixins.Base],
    components: {
        SelectImageCheckbox: async () =>
            Vue.extend(
                await Vue.prototype.$vFN.Components.Base.SelectImageCheckbox()
            ),
    },
    data() {
        return {
            appWindow: window,

            model: "",

            content: "",
            imageUrlLst: [],
            commentId: "",

            visible: false,

            commentLevel: 3,
            texts: ["极差", "差评", "中评", "满意", "好评"],
        };
    },
    methods: {
        rateType(v) {
            v -= 0;
            if (v == 5) {
                return "danger";
            }
            if (v > 2) {
                return "warning";
            }

            return "info";
        },

        // 初始化
        async init() {
            console.log(this.params);
            this.model = this.params;
            this.commentId = this.params.id;
            this.commentLevel = this.params.commentLevel;
            // 显示窗口
            this.visible = true;
        },

        // 取消回复
        cancelReply() {
            console.log("取消");
            // 关闭窗口
            this.visible = false;
        },
        // 确认回复
        confirmReply() {
            console.log("确认回复");
            this.$confirm("确认回复该评论吗?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(async () => {
                    let _res = await this.$vFN.Http.post(
                        {
                            url: "mall-site-portal/comment/commentReplay",
                            data: {
                                commentId: this.commentId,
                                imageUrlLst: this.imageUrlLst,
                                content: this.content,
                            },
                        },
                        window
                    );
                    if (_res._ok) {
                        this.$vFN.Tools.messageSuccess("操作成功");
                        console.log(_res);
                        this.visible = false;
                    }
                })
                .catch(() => {
                    this.$vFN.Tools.messageError("操作失败");
                });
        },
    },
    mounted() {
        this.init();
    },
    activated() {},
};
</script>
